﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 列表类控件练习
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < listView1.SelectedItems.Count; i++)
            {
                string name = listView1.SelectedItems[i].Text;
                bool isNew = true;

                for(int j = 0;j< listBox1.Items.Count; j++)
                {
                    if (listBox1.Items[i].ToString() == name)
                    {
                        isNew = false;
                    }
                }

                if (isNew == false)
                {
                    continue;
                }

                listBox1.Items.Add(listView1.SelectedItems[i].Text);

                progressBar1.Value += (int)((progressBar1.Maximum - progressBar1.Minimum) * 0.2);
            }
        }
    }
}
